{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "8648cf2c-8d30-440c-a1ac-08491bf137cf",
   "metadata": {},
   "outputs": [],
   "source": [
    "from tools import sysinfo"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "0ae190a8-5284-4237-9044-7e3b16bbd0e1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Date:       09/14/24\n",
      "Python:     3.9.17\n",
      "Numpy:      2.0.2\n",
      "Scipy:      1.13.1\n",
      "Matplotlib: 3.9.2\n"
     ]
    }
   ],
   "source": [
    "sysinfo()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "e806519e-5108-46c9-bbdb-c4483f0d8292",
   "metadata": {},
   "outputs": [],
   "source": [
    "class RandomWalker:\n",
    "    def __init__(self):\n",
    "        self.position = 0\n",
    "\n",
    "    def walk(self,n):\n",
    "        self.position = 0\n",
    "        for i in range(n):\n",
    "            yield self.position\n",
    "            self.position += 2*random.randint(0,1) - 1\n",
    "\n",
    "walker = RandomWalker()\n",
    "walk = [position for position in walker.walk(1000)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "6f68fd65-6c05-4174-9972-e55c52baa562",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10 loops, best of 3: 5.83 msec per loop\n"
     ]
    }
   ],
   "source": [
    "from tools import timeit\n",
    "walker = RandomWalker()\n",
    "timeit(\"[position for position in walker.walk(n=10000)]\", globals())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6912dba7-ca69-444a-ae89-5a9da5395a9a",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.17"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
